package com.accp.demo.controller.sale;


import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.accp.demo.pojo.sale.SaleOutStorage;
import com.accp.demo.service.sale.SaleOutStorageService;
//import com.alibaba.fastjson.JSON;

@RestController
@RequestMapping("xsckd")
public class SaleOutStorageController {

	@Autowired
	private SaleOutStorageService saleOutStorageService;
	
	@ResponseBody
	@RequestMapping("saveOrUpdate")
	public Object saveOrUpdate(@RequestBody Map<String, Object> map ){
		//String str = JSON.toJSONString("{billNo:20170519006,billDate:2017-05-19,custNo:10001,wareNo:10001,addressId:1,moneyType:人民币,exchRate:1.00,isTax:1,bizMan:admin,maker:admin,permitter:admin,SaleOutStorageDetail:[{billNo:20170519006,lineId:1,materialNo:10001,quantity:5,oldPrice:5,discount:100,unitPrice:5,amount:25,taxRate:17,tax:4.25,taxAmount:29.25,itemRemark:这人好懒啥都没有留!,isGift:0},{billNo:20170519006,lineId:2,materialNo:10001,quantity:5,oldPrice:5,discount:100,unitPrice:5,amount:25,taxRate:17,tax:4.25,taxAmount:29.25,itemRemark:这人好懒啥都没有留!,isGift:0}]}");
		//System.out.println(JSON.toJSONString(map));
		//return this.saleOutStorageService.add(map);	
//		System.out.println(JSON.toJSONString(map));
		return this.saleOutStorageService.saveOrUpdate(map);
	}
	
	@ResponseBody
	@RequestMapping("test")
	public Object test(){
		List<SaleOutStorage> saleOutStorages = this.saleOutStorageService.findAll();
		/*for (SaleOutStorage saleOutStorage : saleOutStorages) {
			System.out.println(saleOutStorage.toString());	
			for (SaleOutStorageDetail saleOutStorageDetail : saleOutStorage.getSaleOutStorageDetails()) {
				System.out.println(saleOutStorageDetail.toString());
			}
		}*/
		return saleOutStorages;
	}
	
	@ResponseBody
	@RequestMapping("queryByPage")
	public Object queryByPage(@RequestParam Map<String, Object> map){
		return this.saleOutStorageService.queryByPage(map);
	}
	
	@ResponseBody
	@RequestMapping("getNewNo")
	public Object getNewNo(@RequestParam Map<String, Object> map){
		return this.saleOutStorageService.getNewNo(map);
	}
	
	@ResponseBody
	@RequestMapping("updLogicalState")
	public Object updLogicalState(@RequestBody Map<String, Object> map){
		return this.saleOutStorageService.updLogicalState(map);
	}
	
	@ResponseBody
	@RequestMapping("updExamineAfter")
	public Object updExamineAfter(@RequestBody Map<String, Object> map){
		return this.saleOutStorageService.updSaleOutStorageExamineAfter(map);
	}
	
	
	
}
